﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Fraction;

namespace Calc
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.button1.Click += new System.EventHandler(this.button1_Click);
            
        }

        private void huhToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            MessageBox.Show(this, "HUH");
        }

        private Fraction.Fraction f;

        private void button1_Click(object sender, EventArgs e)
        {
            int n, d;
            if (Int32.TryParse(textBox1.Text.Trim(), out n) &&
                Int32.TryParse(textBox2.Text.Trim(), out d))
            {
                try
                {
                    f = new Fraction.Fraction(n, d);
                    label2.Text = f.ToString();
                }
                catch (ZeroDenominatorException zde)
                {
                    label2.Text = @"Den may NOT BE 0. WAS " + zde.Message;
                }
            }
            else
            {
                label2.Text = @"Numbers Only";
            }
            textBox1.Text = string.Empty;
            textBox2.Text = string.Empty;
        }

    }
}
